﻿using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System.Collections.Generic;
using System.ComponentModel;

namespace Little.Soldier.SWIFT.Messages.Category0
{
  public class MT085 : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagDefinition U0004;
    private static SwiftTagSubItemDefinition U0005;
    private static SwiftTagDefinition U0006;
    private static SwiftTagSubItemDefinition U0007;
    private static SwiftTagDefinition U0008;
    private static SwiftTagSubItemDefinition U000E;

    [Description("Section Number")]
    public Tag202 SectionNumber_202
    {
      get
      {
        return new Tag202((SwiftElement) this, 0, (SwiftDefinitionElement) MT085.U0002);
      }
    }

    [Description("Section Number")]
    public Tag202 Tag202_SectionNumber
    {
      get
      {
        return this.SectionNumber_202;
      }
    }

    [Description("Total Sections")]
    public Tag203 TotalSections_203
    {
      get
      {
        return new Tag203((SwiftElement) this, 0, (SwiftDefinitionElement) MT085.U0004);
      }
    }

    [Description("Total Sections")]
    public Tag203 Tag203_TotalSections
    {
      get
      {
        return this.TotalSections_203;
      }
    }

    [Description("ICC Shipment Reference")]
    public Tag220 ICCShipmentReference_220
    {
      get
      {
        return new Tag220((SwiftElement) this, 0, (SwiftDefinitionElement) MT085.U0006);
      }
    }

    [Description("ICC Shipment Reference")]
    public Tag220 Tag220_ICCShipmentReference
    {
      get
      {
        return this.ICCShipmentReference_220;
      }
    }

    [Description("Swift Card Number")]
    public Tag221[] SwiftCardNumber_221
    {
      get
      {
        int index = -1;
        List<Tag221> list = new List<Tag221>();
        int count;
        do
        {
          ++index;
          Tag221 tag221 = new Tag221((SwiftElement) this, index, (SwiftDefinitionElement) MT085.U0008);
          count = this.ListTags((SwiftElement) tag221).Count;
          if (count > 0)
            list.Add(tag221);
        }
        while (count > 0);
        return list.ToArray();
      }
    }

    [Description("Swift Card Number")]
    public Tag221[] Tag221_SwiftCardNumber
    {
      get
      {
        return this.SwiftCardNumber_221;
      }
    }

    public MT085()
      : base(true)
    {
    }

    public MT085(SwiftMessage message)
      : base(message)
    {
    }

    public Tag221 AddSwiftCardNumber_221()
    {
      return new Tag221((SwiftElement) this, this.SwiftCardNumber_221.Length, (SwiftDefinitionElement) MT085.U0008)
      {
        Value = string.Empty
      };
    }

    public void RemoveSwiftCardNumber_221(Tag221 tag)
    {
      this.RemoveTag(tag.GetTag());
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MT085.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MT085.MessageDefinition = new SwiftMessageDefinition("MT085", "ICC Delivery Information");
      MT085.U0002 = new SwiftTagDefinition("SectionNumber_202", "Section Number");
      MT085.U0002.TagName = "{202:";
      MT085.U0002.Mandatory = false;
      MT085.U0003 = new SwiftTagSubItemDefinition("SectionNumber", "Section Number");
      MT085.U0002.Elements.Add((SwiftDefinitionElement) MT085.U0003);
      MT085.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT085.U0002);
      MT085.U0004 = new SwiftTagDefinition("TotalSections_203", "Total Sections");
      MT085.U0004.TagName = "{203:";
      MT085.U0004.Mandatory = false;
      MT085.U0005 = new SwiftTagSubItemDefinition("TotalSections", "Total Sections");
      MT085.U0004.Elements.Add((SwiftDefinitionElement) MT085.U0005);
      MT085.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT085.U0004);
      MT085.U0006 = new SwiftTagDefinition("ICCShipmentReference_220", "ICC Shipment Reference");
      MT085.U0006.TagName = "{220:";
      MT085.U0007 = new SwiftTagSubItemDefinition("ICCShipmentReference", "ICC Shipment Reference");
      MT085.U0006.Elements.Add((SwiftDefinitionElement) MT085.U0007);
      MT085.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT085.U0006);
      MT085.U0008 = new SwiftTagDefinition("SwiftCardNumber_221", "Swift Card Number");
      MT085.U0008.TagName = "{221:";
      MT085.U0008.Multiple = true;
      MT085.U000E = new SwiftTagSubItemDefinition("SwiftCardNumber", "Swift Card Number");
      MT085.U0008.Elements.Add((SwiftDefinitionElement) MT085.U000E);
      MT085.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT085.U0008);
    }
  }
}
